﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LogManager.Base;
using Raven.Client.Indexes;
using Lucene.Net.Documents;

namespace LogManager.LocalStorage.Indexes
{
    /// <summary>
    /// Index to search through events by the custom properties
    /// </summary>
    public class Events_ByProperty : AbstractIndexCreationTask<Event>
    {
        /// <summary>
        /// Creates index
        /// </summary>
        public Events_ByProperty()
        {
            Map = events =>
                from e in events
                select new
                {
                    _ = e.Properties.Select(p => new Field(p.Key, p.Value as string, Field.Store.NO, Field.Index.ANALYZED))
                };
        }
    }
}
